<!DOCTYPE html>
<html>
<head>
  <style>
    body {
      margin: 0;
      overflow: hidden;
      background-color: black;
    }
    canvas {
      display: block;
    }
  </style>
</head>
<body>
  <canvas id="firework-canvas"></canvas>

  <script>
    const canvas = document.getElementById('firework-canvas');
    const ctx = canvas.getContext('2d');
    const fireworks = [];

    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;

    class Firework {
      constructor(x, y) {
        this.x = x;
        this.y = y;
        this.radius = 2;
        this.speed = Math.random() * 3 + 1;
        this.angle = Math.random() * Math.PI * 2;
        this.velocity = {
          x: Math.cos(this.angle) * this.speed,
          y: Math.sin(this.angle) * this.speed
        };
        this.gravity = 0.05;
        this.opacity = 1;
      }

      update() {
        this.x += this.velocity.x;
        this.y += this.velocity.y;
        this.velocity.y += this.gravity;
        this.opacity -= 0.01;

        if (this.radius > 0) {
          this.radius -= 0.1;
        }
      }

      draw() {
        ctx.beginPath();
        ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
        ctx.fillStyle = `rgba(255, 255, 255, ${this.opacity})`;
        ctx.fill();
      }
    }

    function createFirework(x, y) {
      const firework = new Firework(x, y);
      fireworks.push(firework);
    }

    function animate() {
      ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
      ctx.fillRect(0, 0, canvas.width, canvas.height);

      for (let i = 0; i < fireworks.length; i++) {
        fireworks[i].update();
        fireworks[i].draw();

        if (fireworks[i].opacity <= 0) {
          fireworks.splice(i, 1);
        }
      }

      requestAnimationFrame(animate);
    }

    function handleFireworkClick(e) {
      const mouseX = e.clientX;
      const mouseY = e.clientY;
      createFirework(mouseX, mouseY);
    }

    document.addEventListener('click', handleFireworkClick);
    animate();
  </script>
</body>
</html>